<script type='text/javascript'>
$(window).scroll(function(){
        if ($(this).scrollTop() &gt; 500) {
            $(&#39;#slidingbox&#39;).css({&#39;right&#39;:&#39;0px&#39;});
        } else {
            $(&#39;#slidingbox&#39;).css({&#39;right&#39;:&#39;-380px&#39;});
        }
    });
   
$(document).ready(function(){
 var slidingbox      = $(&#39;#slidingbox&#39;);
    var closed      = $(&#39;#slidingbox-close&#39;);
    var minimize    = $(&#39;#slidingbox-minimize&#39;);
    var maximize    = $(&#39;#slidingbox-maximize&#39;);
   
    maximize.hide();
   
    closed.click(function(){
        slidingbox.css({&#39;right&#39;:&#39;-380px&#39;});
        slidingbox.fadeOut(&#39;fold&#39;);
    })
    minimize.click(function(){
        slidingbox.toggle()(&#39;fold&#39;);
        $(this).fold();
        maximize.show();
    })
    maximize.click(function(){
        slidingbox.toggle()(&#39;fold&#39;);
        $(this).fold();
        minimize.show();
    })
});
</script>